<!DOCTYPE html>
<?php
if (SESSION::instance()) {
    include(Kohana::find_file('views', '/user/login'));
} else {
    include(Kohana::find_file('views', '/user/logout'));
}
?>

<html>
    <head>
        <script type="text/javascript" src="<?php echo URL::base() . 'media/js/jquery/jquery-1.7.1.js' ?>"></script> 
        <?php if(SESSION::instance()->get('user_id')!=NULL){ ?>
        <script type="text/javascript">            
            function res_check_and_update_time(){
                var oRequest = new XMLHttpRequest();
                var sURL  = "<?php echo URL::site('user') ?>/updatetime";
                oRequest.open("GET",sURL,false);
                oRequest.setRequestHeader("User-Agent",navigator.userAgent);
                oRequest.send(null);
                setTimeout("update_time()", 5000);
            }
            window.onload = res_check_and_update_time;
        </script>
        <?php } ?>
    </head>
    <body>
        <div id="menu">
            <?php if (SESSION::instance()->get('user_id') != NULL) { ?>
                <ul>
                    <li><a href="<?php echo URL::site('building') ?>">Building</a></li>
                </ul>
            <?php } ?>
        </div>

        <?php if (isset($notice)): ?>
            <div class="notice">
                <?php echo $notice ?>
            </div>
        <?php endif; ?>
        <?php if (isset($error)): ?>
            <div class="error">
                <?php echo $error ?>
            </div>
        <?php endif; ?>
        <?php echo $content ?> 
    </body>
</html>